package com.bjc2.singleton.demo5;

/**
 * @program: DesignPattern
 * @description: 双重检查锁
 * @author: bjc
 * @create: 2022-03-29 20:44
 */
public class Singleton {

    private Singleton(){}

    private volatile static Singleton instance;

    public static Singleton getInstance(){
        if (instance == null){
            synchronized (Singleton.class) {
                if (instance == null) {
                    instance = new Singleton();
                }
            }
        }
        return instance;
    }
}
